package 多线程.线程池;

import org.junit.Test;

import java.util.Collection;
import java.util.Date;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

/**
 * Description
 *
 * @Author: Heiffeng
 * @Date: 2021/12/18 17:45
 */
public class 常用阻塞队列探究 {

    @Test
    public void ArrayBlockingQueue(){
        ArrayBlockingQueue queue = new ArrayBlockingQueue(2);
    }

    @Test
    public void LinkedBlockingQueue无界限定为有界测试(){
        LinkedBlockingQueue queue = new LinkedBlockingQueue(10);
        for (int i = 0; i < 12; i++) {
            queue.add(new Date());
        }
    }
//    java.lang.IllegalStateException: Queue full
//        at java.util.AbstractQueue.add(AbstractQueue.java:98)
//        at 多线程.线程池.常用阻塞队列探究.LinkedBlockingQueue(常用阻塞队列探究.java:27)
}
